﻿using System;

namespace HYRElectric.Calculate
{
	internal class CalRoomParam
	{
		public CalRoomParam(DGVRowData data)
		{
			this.m_dgvRowData = data;
		}

		public double RoomRCR()
		{
			return 2.5 * this.WallAreaVirtualRoom() / this.RoomArea();
		}

		public double RoomRI()
		{
			return 5.0 / this.RoomRCR();
		}

		public int PCeiling()
		{
			double num = this.PaveCeiling();
			double num2 = this.RoomArea() + this.WallAreaCeiling();
			return this.UnPercent(num * this.RoomArea() / (num2 - num * num2 + num * this.RoomArea()));
		}

		public int PWall()
		{
			return this.UnPercent((this.Percent(this.m_dgvRowData.dSBFSXS.dValue) * (this.WallAreaRoom() - this.m_dgvRowData.dCMJ) + this.Percent(this.m_dgvRowData.dCFSXS) * this.m_dgvRowData.dCMJ) / this.WallAreaRoom());
		}

		public int PFloor()
		{
			double num = this.PaveFloor();
			double num2 = this.RoomArea() + this.WallAreaFloor();
			return this.UnPercent(num * this.RoomArea() / (num2 - num * num2 + num * this.RoomArea()));
		}

		private double HCeiling()
		{
			return this.m_dgvRowData.dFJGD - this.m_dgvRowData.dAZGD;
		}

		private double HRoom()
		{
			return this.m_dgvRowData.dAZGD - this.m_dgvRowData.dGZMGD;
		}

		private double RoomArea()
		{
			return this.m_dgvRowData.dFJMJ;
		}

		private double WallAreaCeiling()
		{
			return this.m_dgvRowData.dWallPerimeter * this.HCeiling();
		}

		private double WallAreaRoom()
		{
			return this.m_dgvRowData.dWallPerimeter * this.HRoom();
		}

		private double WallAreaVirtualRoom()
		{
			return this.m_dgvRowData.dPerimeter * this.HRoom();
		}

		private double WallAreaFloor()
		{
			return this.m_dgvRowData.dWallPerimeter * this.m_dgvRowData.dGZMGD;
		}

		private double Percent(double dVar)
		{
			return dVar / 100.0;
		}

		private int UnPercent(double dVar)
		{
			return (int)(dVar * 100.0 + 0.5);
		}

		private double PaveCeiling()
		{
			return (this.Percent(this.m_dgvRowData.dDPFSXS.dValue) * this.RoomArea() + this.Percent(this.m_dgvRowData.dSBFSXS.dValue) * this.WallAreaCeiling()) / (this.RoomArea() + this.WallAreaCeiling());
		}

		private double PaveFloor()
		{
			return (this.Percent(this.m_dgvRowData.dDMFSXS.dValue) * this.RoomArea() + this.Percent(this.m_dgvRowData.dXBFSXS.dValue) * this.WallAreaFloor()) / (this.RoomArea() + this.WallAreaFloor());
		}

		private DGVRowData m_dgvRowData;
	}
}
